package com.example.sxmall.controller;

import com.example.sxmall.service.ShoesService;
import com.example.sxmall.vo.Result;
import com.example.sxmall.vo.params.ComprehensivesearchParams;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RequestMapping("api/shoes/")
@RestController
public class ShoesController {
    @Autowired
    private ShoesService shoesService;

    /**
     * 根据关键词查询
     * @return
     */
    @GetMapping("/findShoes/{keyword}")
    public Result fuzzyFindShoes(@PathVariable("keyword") String keywrod){
        return shoesService.fuzzyFindShoes(keywrod);
    }

    /**
     * 根据品牌、尺码，颜色，类型，综合搜索
     * @param comParams
     * @return
     */
    @GetMapping("comSearchShoes")
    public Result fuzzyFindShoes(@RequestBody ComprehensivesearchParams comParams){
        return shoesService.ComSearch(comParams);
    }
    /**
     * 返回全部鞋子列表信息（鞋子部分信息）
     * @return
     */
    @GetMapping("listShoes")
    public Result findShoes(){
        return shoesService.findShoes();
    }

    /**
     * 最新鞋子
     * @return
     */
    @GetMapping("newShoes")
    public Result newShoes(){
        int limit = 2;
        return shoesService.newShoes(limit);
    }

    /**
     * 热销鞋子
     * 根据销量从高到低排列
     * limit为限制查询个数（当为零时，按销量从高到低查询所有鞋子）；
     * @return
     */
    @GetMapping("hotShoes/{limit}")
    public Result hotShoes(@PathVariable("limit") int limit){
        return shoesService.hotShoes(limit);
    }
    /**
     * 查看品牌鞋子列表（品牌id在路径中）
     * @param sbid
     * @return
     */
    @GetMapping("brandShoes/{sbid}")
    public Result brandShoes(@PathVariable("sbid") int sbid){
        return shoesService.listBrandShoes(sbid);
    }

    /**
     * 降价鞋子列表
     * @return
     */
    @GetMapping("/priceCutShoes")
    public Result priceCutShoes(){
        return shoesService.priceCutShoes();
    }

}
